<script setup lang="ts">
import { NConfigProvider } from 'naive-ui'
import { NaiveProvider } from '@/components/common'
import { useTheme } from '@/hooks/useTheme'
import axios from './utils/request/axios';
import { onMounted } from 'vue';
import store from 'store'

const { theme, themeOverrides } = useTheme()
const login = async () => {
  try {
    const res = await axios.post('/admin-api/system/auth/login', {
      username: 'xuyuan',
      password: '123456',
      rememberMe: true
    });
    store.set('token', res.data.accessToken);
  } catch (error) {
    console.log(error);
  }
};

onMounted(() => {
  // 开发环境
  if (import.meta.env.MODE === 'development') {
    login();
  }
});
</script>

<template>
  <NConfigProvider class="h-full" :theme="theme" :theme-overrides="themeOverrides">
    <NaiveProvider>
      <RouterView />
    </NaiveProvider>
  </NConfigProvider>
</template>
